layui.use(['rate'], function(){
    var rate = layui.rate;
    //只读
    rate.render({
        elem: '.test9'
        ,value: 4.5
        ,readonly: true
        ,half: true
        ,theme: '#ff6633'
    });
});
layui.use(['laypage', 'layer'], function() {
    var laypage = layui.laypage
        , layer = layui.layer;

    //总页数低于页码总数
    laypage.render({
        elem: 'demo0', count: 50,theme: '#FF6633' //数据总数
    });

    document.querySelector("#demo0").onclick= function(event){
        var ele = event.target;
        console.log(  ele.innerText); //获得页码
        if(ele.nodeName =='EM'){
            //  console.log(  ele.innerText); //获得页码
        }
    }

});
var bigBannerImgArray = ["dish01.jpg","dish02.jpg","dish03.jpg","dish04.jpg","dish05.jpg","dish06.jpg"];
$(".praise-number").click(function (event) {
    var ele=event.target;
    var iEle=ele.parentElement.firstElementChild;
    if(ele.className=='pla'){
        iEle=ele.parentElement.parentElement.firstElementChild;
    }
    if(iEle.style[0]==null){
        iEle.style.display="inline-block";
        var a=parseInt(iEle.parentElement.children[1].firstElementChild.innerText);
        iEle.parentElement.children[1].firstElementChild.innerText=a+1;
    }
    else{
        iEle.removeAttribute("style");
        var a=parseInt(iEle.parentElement.children[1].firstElementChild.innerText);
        iEle.parentElement.children[1].firstElementChild.innerText=a-1;
    }
});
$(".dish-pictures-area").click(function (event) {
    var ele=event.target;
    if(ele.className=="bottom-arrow"||ele.className=="top-arrow"){
        ele=ele.parentElement;
    }
    var ulEle=ele.parentElement.parentElement.children[1];
    var liEle=ulEle.children;
    var pic=ulEle.parentElement.parentElement.firstElementChild.firstElementChild;
    if(ele.parentElement.className=="thumb-next"){
        for(var i=0;i<liEle.length;i++){
            if(liEle[i].className=="dish-pic-list-item active"){
                if(i+1==liEle.length){
                    break;
                }
                if(liEle[i+1].className=="dish-pic-list-item hidden"){
                    liEle[i+1].classList.remove("hidden");
                    liEle[i-3].classList.add("hidden");
                    for(var j=0;j<liEle.length;j++){
                        var k=liEle[j].style.top;
                        k=k.replace("px","");
                        k=parseInt(k)-46;
                        k=k.toString()+"px";
                        liEle[j].style.top=k;
                    }
                }

                liEle[i].classList.remove("active");
                liEle[i+1].classList.add("active");

                pic.src="../images/dish_img/"+bigBannerImgArray[i+1];
                break;
            }
        }
    }
    else if(ele.parentElement.className=="thumb-prev"){
        for(var i=0;i<liEle.length;i++){
            if(liEle[i].className=="dish-pic-list-item active"){
                if(i-1<0){
                    break;
                }
                if(liEle[i-1].className=="dish-pic-list-item hidden"){
                    liEle[i-1].classList.remove("hidden");
                    liEle[i].classList.remove("active");
                    liEle[i+3].classList.add("hidden");
                    for(var j=0;j<liEle.length;j++){
                        var k=liEle[j].style.top;
                        k=k.replace("px","");
                        k=parseInt(k)+46;
                        k=k.toString()+"px";
                        liEle[j].style.top=k;
                    }
                }
                liEle[i].classList.remove("active");
                liEle[i-1].classList.add("active");
                pic.src="../images/dish_img/"+bigBannerImgArray[i-1];
                break;
            }
        }
    }

});